import time


def metric(fn):
    def time_calculate(*args, **kwargs):
        print('begin call')
        start_time = time.time()
        result = fn(*args, **kwargs)
        print('end call')
        end_time = time.time()
        print('耗时：{:.4f}s'.format(end_time - start_time))
        return result

    return time_calculate


@metric
def time1(x, y):
    time.sleep(0.0012)
    print('I am time1')
    return x * y


# test
timeAny = time1(2, 7)
print('timeNew: {}'.format(timeAny))
